from Agent.Astar.Astar_Home import *
import Config
#返回回家时候的包裹数量
def go_home_jobs(nowstate,home,env,player):
    aStar = AStar(startpoint=nowstate, endpoint=home, env=env, player=player)
    pathlist = aStar.start()
    visitList = set()
    for point in pathlist:
      mypoint = Config.CHECKERBOARDSIZE * point.y + point.x
      round = env.getAllLegalMoveAroud(mypoint,player,1)

      for oneround in round:
          visitList.add(oneround)

      visitList.add(mypoint)

    rewardNum = 0

    for visitnode in visitList:
        if visitnode in env.reward_states.keys():
            rewardNum = rewardNum + 1

    return rewardNum



def go_home_action(nowstate,home,env,player):
    aStar = AStar(startpoint=nowstate, endpoint=home, env=env, player=player)
    pathlist = aStar.start()

    action, _ = aStar.action()
